package com.generation.utils;

import java.util.Locale;


/**
 * @author mockingjay
 * @date 2023/4/3 - 12:00
 */
public class StringUtils {

    //处理大小写
    public static String processField(String field,Boolean uperCaseFirstLetter){
        StringBuffer bf=new StringBuffer();
        String[] fields=field.split("_");
        //判断是否转第一个字符换为大写
        bf.append(uperCaseFirstLetter?StringUtils.uperCaseFirstLetter(fields[0]):fields[0]);
        for(int i=1 ;i<fields.length;i++){
            bf.append(StringUtils.uperCaseFirstLetter(fields[i]));
        }
        return bf.toString();
    }

    //转换大写
    public static String uperCaseFirstLetter(String field){
        if(!org.apache.commons.lang3.StringUtils.isEmpty(field)){
           return field.substring(0,1).toUpperCase()+field.substring(1);
        }else {
            return field;
        }
    }

    //转换小写
    public static String lowerCaseFirstLetter(String field){
        if(!org.apache.commons.lang3.StringUtils.isEmpty(field)){
            return field.substring(0,1).toLowerCase()+field.substring(1);
        }else {
            return field;
        }
    }
}
